package com.ketangpai.mapper;

import com.ketangpai.entity.Course;
import org.apache.ibatis.annotations.*;

import java.awt.*;
import java.util.List;


    @Mapper
    public interface CourseMapper {
        int deleteByPrimaryKey(Integer id);

        int insert(Course record);

        int insertSelective(Course record);


        Course selectByPrimaryKey(Integer id);

        int updateByPrimaryKeySelective(Course record);

        int updateByPrimaryKey(Course record);




        //添加课程
        int addCourse(Course course);

        @Insert("insert into user_course(account,courseId,status,sClass) values(#{account}, #{courseId}, #{status} ,#{sClass})")
        int SuccessAddCourse(Course course);

        @Select("select courseId courseName manager term academicYear from course  where id =#{courseId}")
        //根据id查找课程
        Course getCourseById(String id);

        //显示所有课程
        @Select("select courseId from user_course ")
        List<Course> showCourse(@Param("id")String id);

        @Select("select * from course  where selecterId =#{courseId}")
        List<Course>getCourseInfo(@Param("selecterId")String selecterId);
        //编辑课程
//        int editCourse(EditCourseDTO editCourseDTO);

        @Select("select courseId from course where teacherId =#{teacherId}")
        List<Course> getAllCourse(@Param("teacherId")String teacherId);


        @Select("select account from user_course where status=1 and courseId=#{courseId}")
        //获取学生成员
        List<String> getStuMember(@Param("courseId")String courseId);

        @Select("select account from user_course where status=0 and courseId=#{courseId}")
        //获取教师成员
        List<String> getTeaMember(@Param("courseId")String courseId);

        //获取BGimg
        @Select("select courseBgUrl from course where courseId =#{courseId}")
        Image  getBGimg(@Param("courseId") String courseId);

        //获取status
        @Select("select status from user_course where account =#{account} and courseId = #{courseId}")
        String getStatus(@Param("account") String account , @Param("courseId") String courseId);


        //教师删除课程
        @Delete("delete from course where courseId = #{courseId} and manager = #{account}")
        String delCourse(@Param("courseId") String courseId,@Param("manager") String account);

        //学生退课
        @Delete("delete from user_course where account=#{account} and courseId =#{courseId}")
        String dropStudent(@Param("account")String account ,@Param("courseId")String courseId);

    }

